﻿using System;
using System.Collections.Generic;
using System.Linq;
using Assist;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Electrical;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.DB.Plumbing;
using Autodesk.Revit.UI;
using YArchitech.Revit;

namespace YArchitech.HVAC
{
	public class ElementSort
	{
		public ElementSort(Autodesk.Revit.DB.Document Doc)
		{
			this.Doc = Doc;
		}

		public List<Reference> GetUpAndDownReference(List<Element> eles)
		{
			double num = ((ViewSection)this.Doc.ActiveView).Origin.Z + ((ViewSection)this.Doc.ActiveView).CropBox.Max.Y;
			double num2 = ((ViewSection)this.Doc.ActiveView).Origin.Z + ((ViewSection)this.Doc.ActiveView).CropBox.Min.Y;
			List<Reference> list = new List<Reference>();
			Level level = null;
			List<PlanarFace> list2 = new List<PlanarFace>();
			List<Element> list3 = new List<Element>();
			list3.AddRange(eles);
			foreach (Element element in (from s in eles
			where s.GetType() == typeof(Wall)
			select s).ToList<Element>())
			{
				Wall wall = (Wall)element;
				if (wall.Orientation.AngleTo(this.Doc.ActiveView.UpDirection) != Math.PI && wall.Orientation.AngleTo(this.Doc.ActiveView.UpDirection) != 0.0)
				{
					list3.Remove(wall);
				}
			}
			foreach (Element element2 in list3)
			{
				if (element2 is Level)
				{
					if (((Level)element2).Elevation >= num2 && ((Level)element2).Elevation <= num)
					{
						if (level == null)
						{
							level = (Level)element2;
						}
						else if (((Level)element2).Elevation < level.Elevation)
						{
							level = (Level)element2;
						}
					}
				}
				else
				{
					try
					{
						PlanarFace faceReference = this.GetFaceReference(element2, this.Doc.ActiveView.UpDirection);
						if (faceReference != null && faceReference.Origin.Z >= num2 && faceReference.Origin.Z <= num)
						{
							list2.Add(faceReference);
						}
					}
					catch (Exception)
					{
					}
					try
					{
						PlanarFace faceReference2 = this.GetFaceReference(element2, -this.Doc.ActiveView.UpDirection);
						if (faceReference2 != null && faceReference2.Origin.Z >= num2 && faceReference2.Origin.Z <= num)
						{
							list2.Add(faceReference2);
						}
					}
					catch (Exception)
					{
					}
				}
			}
			list2 = (from s in list2
			orderby s.Origin.Z descending
			select s).ToList<PlanarFace>();
			if (list2.Count > 1)
			{
				list.Add(this.AddLevelReference(list2.ElementAt(1), this.Doc.ActiveView.RightDirection));
				PlanarFace planarFace = list2.ElementAt(list2.Count<PlanarFace>() - 2);
				if (level != null && planarFace.Origin.Z > level.Elevation)
				{
					if (level.Document.IsLinked)
					{
						DetailCurve detailCurve = this.Doc.Create.NewDetailCurve(this.Doc.ActiveView, new HYLine(new XYZ(this.Doc.ActiveView.Origin.X, this.Doc.ActiveView.Origin.Y, level.Elevation), new XYZ(this.Doc.ActiveView.Origin.X, this.Doc.ActiveView.Origin.Y, level.Elevation) + 0.005 * this.Doc.ActiveView.RightDirection).Line);
						list.Add(new Reference(detailCurve));
					}
					else
					{
						list.Add(level.PlaneReference());
					}
				}
				else
				{
					list.Add(this.AddLevelReference(list2.ElementAt(list2.Count<PlanarFace>() - 2), this.Doc.ActiveView.RightDirection));
				}
			}
			return list;
		}

		private XYZ GetWallDirection(Wall item)
		{
			return (((LocationCurve)item.Location).Curve.GetEndPoint(0) - ((LocationCurve)item.Location).Curve.GetEndPoint(1)).Normalize();
		}

		public RevitLinkInstance GetElemsOfComprhsivPipeline(Autodesk.Revit.DB.Document document, bool operateElems)
		{
			new List<Element>();
			List<Element> list = new List<Element>();
			new List<Element>();
			list = new FilteredElementCollector(document, document.ActiveView.Id).OfCategory(BuiltInCategory.OST_RvtLinks).WhereElementIsNotElementType().ToElements().ToList<Element>();
			if (list.Count > 0)
			{
				List<Element> list2 = new List<Element>();
				using (List<Element>.Enumerator enumerator = list.GetEnumerator())
				{
					if (enumerator.MoveNext())
					{
						Element element = enumerator.Current;
						list2.Clear();
						return element as RevitLinkInstance;
					}
				}
			}
			return null;
		}

		private Reference AddLevelReference(PlanarFace item, XYZ direction)
		{
			new XYZ(this.Doc.ActiveView.Origin.X, this.Doc.ActiveView.Origin.Y, item.Origin.Z);
			Transform transform = ((ViewSection)this.Doc.ActiveView).get_BoundingBox(this.Doc.ActiveView).Transform;
			BoundingBoxXYZ boundingBoxXYZ = this.Doc.ActiveView.get_BoundingBox(this.Doc.ActiveView);
			XYZ xyz = transform.OfPoint(boundingBoxXYZ.Min);
			XYZ xyz2 = transform.OfPoint(boundingBoxXYZ.Max);
			XYZ xyz3 = xyz.Add(xyz2) / 2.0;
			DetailCurve detailCurve;
			if (item.Project(xyz3) != null)
			{
				detailCurve = this.Doc.Create.NewDetailCurve(this.Doc.ActiveView, new HYLine(item.Project(xyz3).XYZPoint, item.Project(xyz3).XYZPoint + 0.005 * direction).Line);
			}
			else
			{
				XYZ xyz4 = new XYZ();
				if (direction.IsAlmostEqualTo(new XYZ(0.0, 0.0, 1.0)))
				{
					xyz4 = new XYZ(item.Origin.X, item.Origin.Y, xyz3.Z);
				}
				else
				{
					xyz4 = new XYZ(xyz3.X, xyz3.Y, item.Origin.Z);
				}
				detailCurve = this.Doc.Create.NewDetailCurve(this.Doc.ActiveView, new HYLine(xyz4, xyz4 + 0.005 * direction).Line);
			}
			return new Reference(detailCurve);
		}

		public List<Reference> GetLeftAndRightReference(List<Element> eles)
		{
			List<Reference> list = new List<Reference>();
			List<PlanarFace> list2 = new List<PlanarFace>();
			eles = (from s in eles
			where s.GetType() == typeof(Wall)
			select s).ToList<Element>();
			foreach (Element element in eles)
			{
				if (Math.Abs(this.GetWallDirection((Wall)element).AngleTo(this.Doc.ActiveView.RightDirection) - Math.PI*.5) < 0.001)
				{
					try
					{
						list2.Add(this.GetFaceReference(element, this.Doc.ActiveView.RightDirection));
						list2.Add(this.GetFaceReference(element, -this.Doc.ActiveView.RightDirection));
					}
					catch (Exception)
					{
					}
				}
			}
			if (Math.Abs(this.Doc.ActiveView.RightDirection.X) > 0.01)
			{
				list2 = (from s in list2
				where s != null
				orderby s.Origin.X descending
				select s).ToList<PlanarFace>();
			}
			else
			{
				list2 = (from s in list2
				where s != null
				orderby s.Origin.Y descending
				select s).ToList<PlanarFace>();
			}
			if (list2.Count >= 4)
			{
				list.Add(this.AddLevelReference(list2.ElementAt(1), this.Doc.ActiveView.UpDirection));
				list.Add(this.AddLevelReference(list2.ElementAt(list2.Count - 2), this.Doc.ActiveView.UpDirection));
			}
			if (list2.Count == 2)
			{
				PlanarFace planarFace = null;
				foreach (PlanarFace planarFace2 in list2)
				{
					if (planarFace == null)
					{
						planarFace = planarFace2;
					}
					else if (planarFace2.Origin.DistanceTo(this.Doc.ActiveView.Origin) <= planarFace.Origin.DistanceTo(this.Doc.ActiveView.Origin))
					{
						planarFace = planarFace2;
					}
				}
				if (planarFace != null)
				{
					list.Add(this.AddLevelReference(planarFace, this.Doc.ActiveView.UpDirection));
				}
			}
			return list;
		}

		private PlanarFace GetFaceReference(Element element, XYZ direction)
		{
			Options options = new Options();
			options.ComputeReferences = true;
			options.IncludeNonVisibleObjects = true;
			if (this.Doc.ActiveView != null)
			{
				options.View = this.Doc.ActiveView;
			}
			else
			{
				options.DetailLevel = (ViewDetailLevel)3;
			}
			foreach (object obj in ((Solid)(from s in element.get_Geometry(options)
			where s.GetType() == typeof(Solid) && ((Solid)s).Volume > 0.001
			select s).FirstOrDefault<GeometryObject>()).Faces)
			{
				Face face = (Face)obj;
				if (!(face is CylindricalFace) && RevitVersionFuncs.GetFaceFaceNormal((PlanarFace)face).IsAlmostEqualTo(direction))
				{
					return (PlanarFace)face;
				}
			}
			return null;
		}

		public List<List<Element>> ColSort(List<Element> eles, bool isLeft, XYZ center)
		{
			Dictionary<Element, XYZ> dictionary = this.GetLocationColForElement(eles);
			if (this.Doc.ActiveView.RightDirection.X > 0.01)
			{
				if (isLeft)
				{
					dictionary = (from s in dictionary
					where s.Value.X < center.X
					orderby s.Value.X
					select s).ToDictionary((KeyValuePair<Element, XYZ> s) => s.Key, (KeyValuePair<Element, XYZ> s) => s.Value);
				}
				else
				{
					dictionary = (from s in dictionary
					where s.Value.X >= center.X
					orderby s.Value.X
					select s).ToDictionary((KeyValuePair<Element, XYZ> s) => s.Key, (KeyValuePair<Element, XYZ> s) => s.Value);
				}
			}
			else if (this.Doc.ActiveView.RightDirection.X < -0.01)
			{
				if (isLeft)
				{
					dictionary = (from s in dictionary
					where s.Value.X > center.X
					orderby s.Value.X descending
					select s).ToDictionary((KeyValuePair<Element, XYZ> s) => s.Key, (KeyValuePair<Element, XYZ> s) => s.Value);
				}
				else
				{
					dictionary = (from s in dictionary
					where s.Value.X <= center.X
					orderby s.Value.X descending
					select s).ToDictionary((KeyValuePair<Element, XYZ> s) => s.Key, (KeyValuePair<Element, XYZ> s) => s.Value);
				}
			}
			else if (this.Doc.ActiveView.RightDirection.Y < 0.0)
			{
				if (isLeft)
				{
					dictionary = (from s in dictionary
					where s.Value.Y > center.Y
					orderby s.Value.Y descending
					select s).ToDictionary((KeyValuePair<Element, XYZ> s) => s.Key, (KeyValuePair<Element, XYZ> s) => s.Value);
				}
				else
				{
					dictionary = (from s in dictionary
					where s.Value.Y <= center.Y
					orderby s.Value.Y descending
					select s).ToDictionary((KeyValuePair<Element, XYZ> s) => s.Key, (KeyValuePair<Element, XYZ> s) => s.Value);
				}
			}
			else if (this.Doc.ActiveView.RightDirection.Y > 0.0)
			{
				if (isLeft)
				{
					dictionary = (from s in dictionary
					where s.Value.Y < center.Y
					orderby s.Value.Y
					select s).ToDictionary((KeyValuePair<Element, XYZ> s) => s.Key, (KeyValuePair<Element, XYZ> s) => s.Value);
				}
				else
				{
					dictionary = (from s in dictionary
					where s.Value.Y >= center.Y
					orderby s.Value.Y
					select s).ToDictionary((KeyValuePair<Element, XYZ> s) => s.Key, (KeyValuePair<Element, XYZ> s) => s.Value);
				}
			}
			return this.GetColLevelList(dictionary, isLeft, center);
		}

		public List<List<Element>> RowSort(List<Element> eles)
		{
			Dictionary<Element, XYZ> dictionary = this.GetLocationForElement(eles);
			dictionary = (from s in dictionary
			orderby s.Value.Z descending
			select s).ToDictionary((KeyValuePair<Element, XYZ> s) => s.Key, (KeyValuePair<Element, XYZ> s) => s.Value);
			return this.GetRowLevelList(dictionary);
		}

		private List<List<Element>> GetColLevelList(Dictionary<Element, XYZ> dic, bool isLeft, XYZ center)
		{
			List<List<Element>> list = new List<List<Element>>();
			if (dic != null && dic.Count > 0)
			{
				List<Element> list2 = new List<Element>();
				List<Element> item = new List<Element>();
				KeyValuePair<Element, XYZ> keyValuePair = default(KeyValuePair<Element, XYZ>);
				if (isLeft)
				{
					keyValuePair = dic.FirstOrDefault<KeyValuePair<Element, XYZ>>();
				}
				else
				{
					keyValuePair = dic.Last<KeyValuePair<Element, XYZ>>();
				}
				if (Math.Abs(this.Doc.ActiveView.RightDirection.X) > 0.01)
				{
					double x = keyValuePair.Value.X;
					Math.Abs(this.getXRadiusOrHeight(keyValuePair.Key, this.Doc.ActiveView.RightDirection));
					double x2 = keyValuePair.Value.X;
					Math.Abs(this.getXRadiusOrHeight(keyValuePair.Key, this.Doc.ActiveView.RightDirection));
					using (Dictionary<Element, XYZ>.Enumerator enumerator = dic.GetEnumerator())
					{
						while (enumerator.MoveNext())
						{
							KeyValuePair<Element, XYZ> keyValuePair2 = enumerator.Current;
							list2.Add(keyValuePair2.Key);
						}
						goto IL_1C4;
					}
				}
				if (Math.Abs(this.Doc.ActiveView.RightDirection.Y) > 0.0)
				{
					double y = keyValuePair.Value.Y;
					Math.Abs(this.getYRadiusOrHeight(keyValuePair.Key, this.Doc.ActiveView.RightDirection));
					double y2 = keyValuePair.Value.Y;
					Math.Abs(this.getYRadiusOrHeight(keyValuePair.Key, this.Doc.ActiveView.RightDirection));
					foreach (KeyValuePair<Element, XYZ> keyValuePair3 in dic)
					{
						list2.Add(keyValuePair3.Key);
					}
				}
				IL_1C4:
				list.Add(list2);
				list.Add(item);
			}
			return list;
		}

		private List<List<Element>> GetRowLevelList(Dictionary<Element, XYZ> dic)
		{
			List<List<Element>> list = new List<List<Element>>();
			if (dic != null && dic.Count > 0)
			{
				List<Element> list2 = new List<Element>();
				List<Element> list3 = new List<Element>();
				double num = dic.FirstOrDefault<KeyValuePair<Element, XYZ>>().Value.Z + Math.Abs(this.GetRadiusOrHeight(dic.FirstOrDefault<KeyValuePair<Element, XYZ>>().Key, false));
				double num2 = dic.FirstOrDefault<KeyValuePair<Element, XYZ>>().Value.Z - Math.Abs(this.GetRadiusOrHeight(dic.FirstOrDefault<KeyValuePair<Element, XYZ>>().Key, false));
				foreach (KeyValuePair<Element, XYZ> keyValuePair in dic)
				{
					if (keyValuePair.Value.Z <= num && keyValuePair.Value.Z >= num2)
					{
						list2.Add(keyValuePair.Key);
					}
					else if (keyValuePair.Key is Duct || keyValuePair.Key is CableTray)
					{
						list2.Add(keyValuePair.Key);
					}
					else
					{
						list3.Add(keyValuePair.Key);
					}
				}
				list.Add(list2);
				list.Add(list3);
			}
			return list;
		}

		private Dictionary<Element, XYZ> GetLocationColForElement(List<Element> eles)
		{
			Dictionary<Element, XYZ> dictionary = new Dictionary<Element, XYZ>();
			Line line = Line.CreateUnbound(this.Doc.ActiveView.Origin, this.Doc.ActiveView.RightDirection);
			foreach (Element element in eles)
			{
				dictionary.Add(element, line.Project(((LocationCurve)element.Location).Curve.GetEndPoint(0)).XYZPoint);
			}
			return dictionary;
		}

		private Dictionary<Element, XYZ> GetLocationForElement(List<Element> eles)
		{
			Dictionary<Element, XYZ> dictionary = new Dictionary<Element, XYZ>();
			foreach (Element element in eles)
			{
				dictionary.Add(element, ((LocationCurve)element.Location).Curve.GetEndPoint(0));
			}
			return dictionary;
		}

		private double getYRadiusOrHeight(Element item, XYZ direction)
		{
			return (direction * this.GetRadiusOrHeight(item, true)).Y;
		}

		private double getXRadiusOrHeight(Element item, XYZ direction)
		{
			return (direction * this.GetRadiusOrHeight(item, true)).X;
		}

		public double GetRadiusOrHeight(Element item, bool isRow = true)
		{
			double result = 0.0;
			double num = 0.0;
			Parameter parameter = item.GetParameter(BuiltInParameter.RBS_REFERENCE_INSULATION_THICKNESS);
			if (parameter != null)
			{
				num = parameter.AsDouble();
			}
			if (item is Pipe)
			{
				result = item.GetParameter(BuiltInParameter.RBS_PIPE_OUTER_DIAMETER).AsDouble() / 2.0 + num;
			}
			else if (item is CableTray)
			{
				if (isRow)
				{
					result = item.GetParameter(BuiltInParameter.RBS_CABLETRAY_WIDTH_PARAM).AsDouble() / 2.0;
				}
				else
				{
					result = item.GetParameter(BuiltInParameter.RBS_CABLETRAY_HEIGHT_PARAM).AsDouble() / 2.0;
				}
			}
			else if (item is Duct)
			{
				Parameter parameter2;
				if (isRow)
				{
					parameter2 = item.GetParameter(BuiltInParameter.RBS_CURVE_WIDTH_PARAM);
				}
				else
				{
					parameter2 = item.GetParameter(BuiltInParameter.RBS_CURVE_HEIGHT_PARAM);
				}
				Parameter parameter3 = item.GetParameter(BuiltInParameter.RBS_CURVE_DIAMETER_PARAM);
				if (parameter2 != null)
				{
					result = parameter2.AsDouble() / 2.0 + num;
				}
				else if (parameter3 != null)
				{
					result = parameter3.AsDouble() / 2.0 + num;
				}
			}
			else if (item is Conduit)
			{
				result = item.GetParameter(BuiltInParameter.RBS_CONDUIT_OUTER_DIAM_PARAM).AsDouble() / 2.0;
			}
			return result;
		}

		public XYZ GetDirectionInstance(List<Element> eles, XYZ direction, bool isUp = true)
		{
			if (direction.IsAlmostEqualTo(new XYZ(0.0, 0.0, 1.0)))
			{
				List<Element> list = new List<Element>();
				list.AddRange(eles);
				foreach (Element element in list)
				{
					if (element is Wall && !((Wall)element).Orientation.Normalize().IsAlmostEqualTo(this.Doc.ActiveView.RightDirection.Normalize(), 0.0001) && !((Wall)element).Orientation.Normalize().IsAlmostEqualTo(this.Doc.ActiveView.RightDirection.Normalize() * -1.0, 0.0001))
					{
						eles.Remove(element);
					}
				}
			}
			List<Element> eles2 = (from s in eles
			where !(s is Level)
			select s).ToList<Element>();
			Dictionary<Element, XYZ> source = this.GetPointForElement(eles2, direction, isUp);
			if (direction.IsAlmostEqualTo(new XYZ(0.0, 0.0, 1.0)))
			{
				source = (from s in source
				orderby s.Value.Z descending
				select s).ToDictionary((KeyValuePair<Element, XYZ> s) => s.Key, (KeyValuePair<Element, XYZ> s) => s.Value);
			}
			else if (direction.X > 0.01)
			{
				source = (from s in source
				orderby s.Value.X descending
				select s).ToDictionary((KeyValuePair<Element, XYZ> s) => s.Key, (KeyValuePair<Element, XYZ> s) => s.Value);
			}
			else if (direction.X < -0.01)
			{
				source = (from s in source
				orderby s.Value.X
				select s).ToDictionary((KeyValuePair<Element, XYZ> s) => s.Key, (KeyValuePair<Element, XYZ> s) => s.Value);
			}
			else if (direction.Y > 0.0)
			{
				source = (from s in source
				orderby s.Value.Y descending
				select s).ToDictionary((KeyValuePair<Element, XYZ> s) => s.Key, (KeyValuePair<Element, XYZ> s) => s.Value);
			}
			else if (direction.Y < 0.0)
			{
				source = (from s in source
				orderby s.Value.Y
				select s).ToDictionary((KeyValuePair<Element, XYZ> s) => s.Key, (KeyValuePair<Element, XYZ> s) => s.Value);
			}
			return source.FirstOrDefault<KeyValuePair<Element, XYZ>>().Value;
		}

		private Dictionary<Element, XYZ> GetPointForElement(List<Element> eles, XYZ direction, bool isUp)
		{
			Transform transform = ((ViewSection)this.Doc.ActiveView).get_BoundingBox(this.Doc.ActiveView).Transform;
			BoundingBoxXYZ boundingBoxXYZ = this.Doc.ActiveView.get_BoundingBox(this.Doc.ActiveView);
			XYZ xyz = transform.OfPoint(boundingBoxXYZ.Min);
			XYZ xyz2 = transform.OfPoint(boundingBoxXYZ.Max);
			double num = 0.0;
			if (xyz.Z > xyz2.Z)
			{
				num = xyz.Z;
				double z = xyz2.Z;
			}
			else
			{
				num = xyz2.Z;
				double z2 = xyz.Z;
			}
			Dictionary<Element, XYZ> dictionary = new Dictionary<Element, XYZ>();
			Line line = Line.CreateUnbound(this.Doc.ActiveView.Origin, direction);
			foreach (Element element in eles)
			{
				if (element.Document.IsLinked)
				{
					if (element is Duct || element is CableTray || element is Pipe || element is Conduit)
					{
						XYZ pointInLinkDocument = this.Doc.GetLinkedDocument(element.Id).GetPointInLinkDocument(line.Project(((LocationCurve)element.Location).Curve.GetEndPoint(0)).XYZPoint);
						dictionary.Add(element, pointInLinkDocument);
					}
					else if (isUp)
					{
						XYZ xyz3 = null;
						try
						{
							xyz3 = this.GetFacePoint(element, direction);
						}
						catch (Exception)
						{
							continue;
						}
						if (xyz3 != null && xyz3.Z <= num)
						{
							dictionary.Add(element, xyz3);
						}
					}
				}
				else if (element is Duct || element is CableTray || element is Pipe || element is Conduit)
				{
					dictionary.Add(element, line.Project(((LocationCurve)element.Location).Curve.GetEndPoint(0)).XYZPoint);
				}
				else if (isUp)
				{
					XYZ xyz4 = null;
					try
					{
						xyz4 = this.GetFacePoint(element, direction);
					}
					catch (Exception)
					{
						continue;
					}
					if (xyz4 != null && xyz4.Z <= num)
					{
						dictionary.Add(element, xyz4);
					}
				}
			}
			return (from s in dictionary
			where s.Value != null
			select s).ToDictionary((KeyValuePair<Element, XYZ> s) => s.Key, (KeyValuePair<Element, XYZ> s) => s.Value);
		}

		public XYZ GetFacePoint(Element element, XYZ direction)
		{
			if (!(element is Level))
			{
				foreach (GeometryObject geometryObject in element.get_Geometry(this.GetGeomOptions()))
				{
					foreach (object obj in (geometryObject as Solid).Faces)
					{
						Face face = (Face)obj;
						if (!(face is CylindricalFace) && RevitVersionFuncs.GetFaceFaceNormal((PlanarFace)face).IsAlmostEqualTo(direction))
						{
							if (element.Document.IsLinked)
							{
								return this.Doc.GetLinkedDocument(element.Id).GetPointInLinkDocument(Line.CreateUnbound(this.Doc.ActiveView.Origin, direction).Project(((PlanarFace)face).Origin).XYZPoint);
							}
							return Line.CreateUnbound(this.Doc.ActiveView.Origin, direction).Project(((PlanarFace)face).Origin).XYZPoint;
						}
					}
				}
				return null;
			}
			if (element.Document.IsLinked)
			{
				return this.Doc.GetLinkedDocument(element.Id).GetPointInLinkDocument(Line.CreateUnbound(this.Doc.ActiveView.Origin, direction).Project(new XYZ(0.0, 0.0, ((Level)element).Elevation)).XYZPoint);
			}
			return Line.CreateUnbound(this.Doc.ActiveView.Origin, direction).Project(new XYZ(0.0, 0.0, ((Level)element).Elevation)).XYZPoint;
		}

		private Options GetGeomOptions()
		{
			Options options = new UIDocument(this.Doc).Application.Application.Create.NewGeometryOptions();
			options.ComputeReferences = true;
			options.DetailLevel = (ViewDetailLevel)3;
			return options;
		}

		private Document Doc;
	}
}
